{load href="/static/zTree/js/jquery.ztree.all.min.js" /}
{load href="/static/zTree/css/zTreeStyle/zTreeStyle.css" /}
<SCRIPT LANGUAGE="JavaScript">
    var zTreeObj;
    var editNodeId;//当前编辑的节点id
    var editType;//当前编辑类型1添加子节点2编辑
    // zTree 的参数配置，深入使用请参考 API 文档（setting 配置详解）
    var setting = {
        view: {
            addHoverDom: addHoverDom,
            removeHoverDom: removeHoverDom,
            selectedMulti: false
        },
        edit: {
            enable: true,
            editNameSelectAll: true,
            showRemoveBtn: showRemoveBtn,
            showRenameBtn: true,
            removeTitle: '删除',
            renameTitle: '编辑',
            drag: {
                isCopy: false,
                inner: false
            }
        },
        data: {
            simpleData: {
                enable: true,
                'idKey': 'id',
                'pIdKey': 'parentid',
                'rootPId': 0
            }
        },
        callback: {
            beforeDrag: beforeDrag,
            beforeDrop: beforeDrop,
            onDrop: onDrop,
            beforeEditName: beforeEditName,
            beforeRemove: beforeRemove
        }
    };
    // zTree 的数据属性，深入使用请参考 API 文档（zTreeNode 节点数据详解）
    var zNodes = {$menu};
    //[{"id": "3", "pid": "2", "name": "\u83dc\u5355\u5217\u8868", "m": "Stb", "c": "menu", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "4", "pid": "3", "name": "\u6dfb\u52a0\u83dc\u5355", "m": "Stb", "c": "menu", "a": "add", "list_order": "0", "ll": "3", "display": "1", "data": ""}, {"id": "11", "pid": "3", "name": "\u83dc\u5355\u7f16\u8f91", "m": "Stb", "c": "menu", "a": "edit", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "15", "pid": "0", "name": "\u6211\u7684\u9762\u677f", "m": "Stb", "c": "index", "a": "", "list_order": "0", "ll": "1", "display": "0", "data": ""}, {"id": "16", "pid": "15", "name": "\u767b\u5f55\u9875", "m": "Stb", "c": "index", "a": "login", "list_order": "0", "ll": "2", "display": "0", "data": ""}, {"id": "17", "pid": "15", "name": "\u6211\u7684\u4fe1\u606f", "m": "Stb", "c": "index", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "18", "pid": "15", "name": "\u9000\u51fa", "m": "Stb", "c": "index", "a": "logout", "list_order": "0", "ll": "2", "display": "0", "data": ""}, {"id": "27", "pid": "20", "name": "\u8bfe\u7a0b\u5217\u8868", "m": "Stb", "c": "instance", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "28", "pid": "20", "name": "\u6dfb\u52a0\u8bfe\u7a0b", "m": "Stb", "c": "instance", "a": "add", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "29", "pid": "27", "name": "\u7f16\u8f91\u5b9e\u4f8b", "m": "Stb", "c": "instance", "a": "edit", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "30", "pid": "27", "name": "\u53d1\u5e03\u8bfe\u7a0b", "m": "Stb", "c": "course", "a": "online", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "32", "pid": "31", "name": "\u8bfe\u5802\u8868", "m": "Stb", "c": "arrange", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "33", "pid": "31", "name": "\u7f16\u8f91\u8bfe\u5802", "m": "Stb", "c": "arrange", "a": "edit", "list_order": "0", "ll": "2", "display": "0", "data": ""}, {"id": "34", "pid": "31", "name": "\u6dfb\u52a0\u8bfe\u5802", "m": "Stb", "c": "arrange", "a": "add", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "47", "pid": "44", "name": "\u7528\u6237\u7edf\u8ba1", "m": "Stb", "c": "Stat", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "48", "pid": "44", "name": "\u8ba2\u5355\u7edf\u8ba1", "m": "Stb", "c": "Stat", "a": "order", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "49", "pid": "72", "name": "\u5ba2\u6237\u7aef", "m": "Stb", "c": "version", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "51", "pid": "50", "name": "\u4e0a\u4f20\u56fe\u7247", "m": "Stb", "c": "Ajax", "a": "upoladImage", "list_order": "0", "ll": "2", "display": "0", "data": ""}, {"id": "52", "pid": "49", "name": "\u4e0a\u4f20\u65b0\u7248\u672c", "m": "Stb", "c": "version", "a": "add", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "56", "pid": "54", "name": "\u7f16\u8f91\u8bd5\u9898", "m": "Stb", "c": "question", "a": "edit", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "59", "pid": "58", "name": "\u7f16\u8f91\u6750\u6599", "m": "Stb", "c": "question", "a": "editInfo", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "60", "pid": "58", "name": "\u6750\u6599\u8bd5\u9898", "m": "Stb", "c": "question", "a": "infoQuest", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "62", "pid": "53", "name": "\u771f\u9898\u8bd5\u5377", "m": "Stb", "c": "paper", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "64", "pid": "63", "name": "\u7528\u6237", "m": "Stb", "c": "qcloud", "a": "user", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "65", "pid": "63", "name": "\u7fa4\u7ec4", "m": "Stb", "c": "qcloud", "a": "group", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "66", "pid": "63", "name": "\u76f4\u64ad\u9891\u9053", "m": "Stb", "c": "qcloud", "a": "live", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "69", "pid": "67", "name": "\u7f16\u8f91\u82f9\u679c\u5546\u54c1", "m": "Stb", "c": "instance", "a": "editpro", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "70", "pid": "55", "name": "\u7f16\u8f91\u5206\u7c7b", "m": "Stb", "c": "question", "a": "editType", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "71", "pid": "55", "name": "\u6dfb\u52a0\u8bd5\u9898\u5206\u7c7b", "m": "Stb", "c": "question", "a": "addType", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "73", "pid": "72", "name": "\u5e7f\u544a", "m": "Stb", "c": "ad", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "74", "pid": "73", "name": "\u5e7f\u544a\u5217\u8868", "m": "Stb", "c": "ad", "a": "adlist", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "75", "pid": "73", "name": "\u6dfb\u52a0\u5e7f\u544a", "m": "Stb", "c": "ad", "a": "aad", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "76", "pid": "73", "name": "\u7f16\u8f91\u5e7f\u544a", "m": "Stb", "c": "ad", "a": "ead", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "77", "pid": "73", "name": "\u5220\u9664\u5e7f\u544a", "m": "Stb", "c": "ad", "a": "del", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "78", "pid": "42", "name": "\u7528\u6237\u5217\u8868", "m": "Stb", "c": "user", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "82", "pid": "72", "name": "\u5bfc\u51fa", "m": "Stb", "c": "export", "a": "index", "list_order": "0", "ll": "2", "display": "0", "data": ""}, {"id": "83", "pid": "27", "name": "\u66f4\u65b0\u8bfe\u7a0b\u5c01\u9762", "m": "Stb", "c": "instance", "a": "reCover", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "84", "pid": "27", "name": "\u66f4\u65b0\u8bfe\u7a0b\u5206\u7c7b", "m": "Stb", "c": "instance", "a": "reCtype", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "85", "pid": "72", "name": "\u7528\u6237\u53cd\u9988", "m": "Stb", "c": "feedback", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "86", "pid": "72", "name": "\u4f1a\u5458\u7c7b\u578b", "m": "Stb", "c": "member", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "88", "pid": "86", "name": "\u6dfb\u52a0\u4f1a\u5458\u7c7b\u578b", "m": "Stb", "c": "member", "a": "add", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "89", "pid": "86", "name": "\u7f16\u8f91\u4f1a\u5458\u7c7b\u578b", "m": "Stb", "c": "member", "a": "edit", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "90", "pid": "43", "name": "\u4f1a\u5458\u8ba2\u5355", "m": "", "c": "order", "a": "vip", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "91", "pid": "42", "name": "VIP\u4f1a\u5458", "m": "Stb", "c": "user", "a": "vip", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "92", "pid": "43", "name": "\u8bfe\u7a0b\u8ba2\u5355", "m": "Stb", "c": "order", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "93", "pid": "72", "name": "\u788e\u7247\u7ba1\u7406", "m": "Stb", "c": "debris", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "94", "pid": "93", "name": "\u6dfb\u52a0\u788e\u7247", "m": "Stb", "c": "debris", "a": "add", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "95", "pid": "93", "name": "\u7f16\u8f91\u788e\u7247", "m": "Stb", "c": "debris", "a": "edit", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "96", "pid": "85", "name": "\u5904\u7406\u53cd\u9988", "m": "Stb", "c": "feedback", "a": "reply", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "97", "pid": "58", "name": "\u4fee\u6539\u8d44\u6599\u72b6\u6001", "m": "Stb", "c": "question", "a": "infoline", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "98", "pid": "62", "name": "\u7f16\u8f91\u8bd5\u5377", "m": "Stb", "c": "paper", "a": "edit", "list_order": "0", "ll": "3", "display": "1", "data": ""}, {"id": "99", "pid": "62", "name": "\u7f16\u8f91\u8bd5\u5377\u8bd5\u9898", "m": "Stb", "c": "paper", "a": "detail", "list_order": "0", "ll": "3", "display": "1", "data": ""}, {"id": "100", "pid": "62", "name": "\u79fb\u9664\u8bd5\u9898", "m": "Stb", "c": "paper", "a": "delmatter", "list_order": "0", "ll": "3", "display": "1", "data": ""}, {"id": "101", "pid": "62", "name": "\u8bd5\u9898\u6539\u53d8\u6a21\u5757", "m": "Stb", "c": "paper", "a": "moveitem", "list_order": "0", "ll": "3", "display": "1", "data": ""}, {"id": "102", "pid": "92", "name": "\u7ed3\u675f\u8ba2\u5355", "m": "Stb", "c": "order", "a": "overOrder", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "103", "pid": "27", "name": "\u8bfe\u7a0b\u4e0b\u67b6", "m": "Stb", "c": "instance", "a": "soldOut", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "104", "pid": "43", "name": "\u6279\u91cf\u9000\u5355", "m": "Stb", "c": "order", "a": "batch", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "107", "pid": "44", "name": "\u8bd5\u9898\u7edf\u8ba1", "m": "Stb", "c": "stat", "a": "answer", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "108", "pid": "110", "name": "\u67e5\u770b\u9884\u7ea6\u7528\u6237", "m": "Stb", "c": "reservation", "a": "yuser", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "109", "pid": "110", "name": "\u6dfb\u52a0\u6a21\u8003\u9884\u7ea6\u5377", "m": "Stb", "c": "reservation", "a": "add", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "110", "pid": "53", "name": "\u6a21\u8003\u9884\u7ea6", "m": "Stb", "c": "reservation", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "111", "pid": "62", "name": "\u968f\u673a\u62bd\u9898", "m": "Stb", "c": "paper", "a": "random", "list_order": "0", "ll": "3", "display": "1", "data": ""}, {"id": "116", "pid": "2", "name": "\u7ba1\u7406\u5458", "m": "Stb", "c": "power", "a": "admin", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "117", "pid": "116", "name": "\u7f16\u8f91\u7ba1\u7406\u5458", "m": "Stb", "c": "power", "a": "editAdmin", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "118", "pid": "116", "name": "\u7f16\u8f91\u7ba1\u7406\u5458\u6743\u9650", "m": "Stb", "c": "power", "a": "editAdminPower", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "119", "pid": "116", "name": "\u6dfb\u52a0\u7ba1\u7406\u5458", "m": "Stb", "c": "power", "a": "addAdmin", "list_order": "0", "ll": "3", "display": "1", "data": ""}, {"id": "122", "pid": "27", "name": "\u5c06\u8bfe\u7a0b\u63a8\u9001\u5230\u5206\u6821\u8bfe\u7a0b", "m": "Stb", "c": "berkeley", "a": "toberkeley", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "123", "pid": "43", "name": "\u666e\u901a\u8bfe\u8d60\u9001\u8bb0\u5f55", "m": "Stb", "c": "order", "a": "giveRecord", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "124", "pid": "43", "name": "\u7cfb\u7edf\u8bfe\u8d2d\u4e70\u8bb0\u5f55", "m": "Stb", "c": "order", "a": "tutoring", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "130", "pid": "0", "name": "\u6587\u7ae0\u7ba1\u7406", "m": "Stb", "c": "Article", "a": "", "list_order": "0", "ll": "1", "display": "1", "data": ""}, {"id": "131", "pid": "130", "name": "\u6587\u7ae0\u5217\u8868", "m": "Stb", "c": "article", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "132", "pid": "130", "name": "\u6dfb\u52a0\u6587\u7ae0", "m": "Stb", "c": "article", "a": "add", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "133", "pid": "130", "name": "\u5220\u9664\u6587\u7ae0", "m": "Stb", "c": "article", "a": "delete", "list_order": "0", "ll": "2", "display": "0", "data": ""}, {"id": "134", "pid": "130", "name": "\u7f16\u8f91\u6587\u7ae0", "m": "Stb", "c": "article", "a": "edit", "list_order": "0", "ll": "2", "display": "0", "data": ""}, {"id": "135", "pid": "72", "name": "\u53cb\u60c5\u94fe\u63a5", "m": "Stb", "c": "links", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "136", "pid": "135", "name": "\u6dfb\u52a0\u53cb\u60c5\u94fe\u63a5", "m": "Stb", "c": "links", "a": "add", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "137", "pid": "135", "name": "\u7f16\u8f91\u53cb\u60c5\u94fe\u63a5", "m": "Stb", "c": "links", "a": "edit", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "138", "pid": "135", "name": "\u5220\u9664\u53cb\u60c5\u94fe\u63a5", "m": "Stb", "c": "links", "a": "delete", "list_order": "0", "ll": "3", "display": "0", "data": ""}, {"id": "139", "pid": "72", "name": "\u63a8\u8350\u4f4d", "m": "Stb", "c": "position", "a": "index", "list_order": "0", "ll": "2", "display": "1", "data": ""}, {"id": "140", "pid": "139", "name": "\u63a8\u8350\u4fe1\u606f\u5217\u8868", "m": "Stb", "c": "position", "a": "poslist", "list_order": "0", "ll": "0", "display": "1", "data": ""}, {"id": "141", "pid": "139", "name": "\u5220\u9664\u63a8\u8350\u4fe1\u606f", "m": "Stb", "c": "position", "a": "del", "list_order": "0", "ll": "3", "display": "1", "data": ""}, {"id": "142", "pid": "139", "name": "\u7f16\u8f91\u63a8\u8350\u4f4d", "m": "Stb", "c": "position", "a": "edit", "list_order": "0", "ll": "3", "display": "1", "data": ""}, {"id": "143", "pid": "139", "name": "\u6dfb\u52a0\u63a8\u8350\u4f4d", "m": "Stb", "c": "position", "a": "add", "list_order": "0", "ll": "3", "display": "1", "data": ""}, {"id": "20", "pid": "0", "name": "\u8bfe\u7a0b", "m": "Stb", "c": "course", "a": "", "list_order": "1", "ll": "1", "display": "1", "data": ""}, {"id": "54", "pid": "53", "name": "\u8bd5\u9898\u5217\u8868", "m": "Stb", "c": "question", "a": "index", "list_order": "1", "ll": "2", "display": "1", "data": ""}, {"id": "79", "pid": "42", "name": "\u6dfb\u52a0\u7528\u6237", "m": "Stb", "c": "user", "a": "add", "list_order": "1", "ll": "2", "display": "1", "data": ""}, {"id": "53", "pid": "0", "name": "\u8bd5\u9898", "m": "Stb", "c": "question", "a": "", "list_order": "2", "ll": "1", "display": "1", "data": ""}, {"id": "58", "pid": "53", "name": "\u9605\u8bfb\u6750\u6599", "m": "Stb", "c": "question", "a": "information", "list_order": "2", "ll": "2", "display": "1", "data": ""}, {"id": "80", "pid": "42", "name": "\u4ee3\u5ba2\u4e0b\u5355", "m": "Stb", "c": "user", "a": "valet", "list_order": "2", "ll": "2", "display": "1", "data": ""}, {"id": "106", "pid": "43", "name": "\u8d60\u9001\u7cfb\u7edf\u8bfe", "m": "Stb", "c": "order", "a": "giving", "list_order": "2", "ll": "2", "display": "1", "data": ""}, {"id": "36", "pid": "0", "name": "\u8bb2\u5e08\u7ba1\u7406", "m": "Stb", "c": "teacher", "a": "", "list_order": "3", "ll": "1", "display": "1", "data": ""}, {"id": "55", "pid": "53", "name": "\u8bd5\u9898\u5206\u7c7b", "m": "Stb", "c": "question", "a": "type", "list_order": "3", "ll": "2", "display": "1", "data": ""}, {"id": "81", "pid": "42", "name": "\u7528\u6237\u6536\u4ef6\u5730\u5740", "m": "Stb", "c": "user", "a": "addr", "list_order": "3", "ll": "2", "display": "1", "data": ""}, {"id": "42", "pid": "0", "name": "\u7528\u6237\u7ba1\u7406", "m": "Stb", "c": "user", "a": "", "list_order": "4", "ll": "1", "display": "1", "data": ""}, {"id": "57", "pid": "53", "name": "\u6dfb\u52a0\u8bd5\u9898", "m": "Stb", "c": "question", "a": "add", "list_order": "4", "ll": "2", "display": "1", "data": ""}, {"id": "43", "pid": "0", "name": "\u8ba2\u5355\u7ba1\u7406", "m": "Stb", "c": "order", "a": "", "list_order": "5", "ll": "1", "display": "1", "data": ""}, {"id": "61", "pid": "53", "name": "\u6dfb\u52a0\u6750\u6599", "m": "Stb", "c": "question", "a": "addInfo", "list_order": "5", "ll": "2", "display": "1", "data": ""}, {"id": "44", "pid": "0", "name": "\u7edf\u8ba1", "m": "Stb", "c": "Stat", "a": "", "list_order": "6", "ll": "1", "display": "1", "data": ""}, {"id": "10", "pid": "3", "name": "\u83dc\u5355\u5220\u9664", "m": "Stb", "c": "menu", "a": "del", "list_order": "7", "ll": "3", "display": "0", "data": ""}, {"id": "72", "pid": "0", "name": "\u6269\u5c55", "m": "Stb", "c": "", "a": "", "list_order": "7", "ll": "1", "display": "1", "data": ""}, {"id": "9", "pid": "2", "name": "\u751f\u6210URL", "m": "Stb", "c": "menu", "a": "createurl", "list_order": "8", "ll": "2", "display": "1", "data": ""}, {"id": "63", "pid": "0", "name": "\u4e91\u901a\u8baf", "m": "Stb", "c": "qcloud", "a": "index", "list_order": "8", "ll": "1", "display": "1", "data": ""}, {"id": "2", "pid": "0", "name": "\u6743\u9650\u7ba1\u7406", "m": "Stb", "c": "menu", "a": "", "list_order": "9", "ll": "1", "display": "1", "data": ""}, {"id": "35", "pid": "20", "name": "\u8bfe\u7a0b\u5206\u7c7b", "m": "Stb", "c": "course", "a": "type", "list_order": "12", "ll": "2", "display": "1", "data": ""}, {"id": "67", "pid": "20", "name": "\u82f9\u679c\u5546\u57ce\u5546\u54c1", "m": "Stb", "c": "instance", "a": "apple", "list_order": "13", "ll": "2", "display": "1", "data": ""}, {"id": "68", "pid": "67", "name": "\u6dfb\u52a0\u82f9\u679c\u5546\u54c1", "m": "Stb", "c": "instance", "a": "addpro", "list_order": "14", "ll": "3", "display": "0", "data": ""}, {"id": "37", "pid": "36", "name": "\u8bb2\u5e08\u5217\u8868", "m": "Stb", "c": "teacher", "a": "index", "list_order": "16", "ll": "2", "display": "1", "data": ""}, {"id": "38", "pid": "36", "name": "\u6dfb\u52a0\u8bb2\u5e08", "m": "Stb", "c": "teacher", "a": "add", "list_order": "16", "ll": "2", "display": "1", "data": ""}, {"id": "39", "pid": "37", "name": "\u7f16\u8f91\u8bb2\u5e08", "m": "Stb", "c": "teacher", "a": "edit", "list_order": "16", "ll": "3", "display": "0", "data": ""}, {"id": "40", "pid": "37", "name": "\u89e3\u7ea6", "m": "Stb", "c": "teacher", "a": "del", "list_order": "16", "ll": "3", "display": "0", "data": ""}, {"id": "41", "pid": "37", "name": "\u7b7e\u7ea6", "m": "Stb", "c": "teacher", "a": "online", "list_order": "16", "ll": "3", "display": "0", "data": ""}, {"id": "45", "pid": "78", "name": "\u9501\u5b9a\u7528\u6237", "m": "Stb", "c": "user", "a": "del", "list_order": "16", "ll": "3", "display": "0", "data": ""}, {"id": "46", "pid": "78", "name": "\u7528\u6237\u89e3\u9501", "m": "Stb", "c": "user", "a": "online", "list_order": "16", "ll": "3", "display": "0", "data": ""}, {"id": "121", "pid": "20", "name": "\u5206\u6821\u8bfe\u7a0b", "m": "Stb", "c": "berkeley", "a": "instance", "list_order": "20", "ll": "2", "display": "1", "data": ""}, {"id": "31", "pid": "0", "name": "\u8bfe\u7a0b\u5b89\u6392", "m": "Stb", "c": "arrange", "a": "", "list_order": "21", "ll": "1", "display": "0", "data": ""}, {"id": "50", "pid": "0", "name": "AJAX", "m": "Stb", "c": "Ajax", "a": "", "list_order": "22", "ll": "1", "display": "0", "data": ""}, {"id": "125", "pid": "20", "name": "\u8bfe\u7a0b\u76f4\u64ad\u9891\u9053\u8bbe\u7f6e", "m": "Stb", "c": "instance", "a": "live", "list_order": "122", "ll": "2", "display": "1", "data": ""}];
    var log, className = "dark";
    /**
     * 禁止一级节点拖拽
     * @param {type} treeId
     * @param {type} treeNodes
     * @returns {Boolean}
     */
    function beforeDrag(treeId, treeNodes) {
        return treeNodes[0].level;
        //return true;
    }

    /**
     * 拖拽放下前回调
     * @param {type} treeId
     * @param {type} treeNodes
     * @param {type} targetNode
     * @returns {Boolean}
     */
    function beforeDrop(treeId, treeNodes, targetNode) {

        console.log(treeNodes);
        console.log(targetNode);
        if (treeNodes[0].parentid === targetNode.parentid) {
            return true;
        } else {
            showLog(getTime() + ':' + '禁止跨节点移动');
            return false;
        }
    }

    /**
     * 拖拽完成
     * @param {type} event
     * @param {type} treeId
     * @param {type} treeNodes
     * @param {type} targetNode
     * @param {type} moveType
     * @returns {Boolean}
     */
    function onDrop(event, treeId, treeNodes, targetNode, moveType) {
        if (!moveType) {
            return false;
        }

        //先找到父节点，再找子节点的排序，同步给后台
        var parentNode = targetNode.getParentNode();
        console.log('111',parentNode);
        var order = {};
        $.each(parentNode.children, function (index, item) {
            order[index] = item.id;
        });
        console.log(order);
        stbAjax('{:url("power/setMenuSort")}', order, function (result) {
            if (result.code > 0) {
                showLog('排序同步后台成功');
                //toast('恭喜', '排序同步后台成功', 800);
            } else {
                toast('失败', data.msg, 2000);
            }
        });

    }

    /**
     * 编辑节点
     * @param {type} treeId
     * @param {type} treeNode
     * @returns {Boolean}
     */
    function beforeEditName(treeId, treeNode) {
        showEditModal(treeNode);
        return false;
    }
    /**
     * 删除节点
     * @param {type} treeId
     * @param {type} treeNode
     * @returns {unresolved}
     */
    function beforeRemove(treeId, treeNode) {
        editNodeId = treeNode.pid;
        editType = 3;
        className = (className === "dark" ? "" : "dark");
        showLog("[ " + getTime() + " beforeRemove ]&nbsp;&nbsp;&nbsp;&nbsp; " + treeNode.name);
        var zTree = $.fn.zTree.getZTreeObj("treeDemo");
        zTree.selectNode(treeNode);
        stbConfirm({title: "确认?", message: "确认删除 节点 -- " + treeNode.name + " 吗？", operate: function (reselt) {
                if (reselt) {
                    $.post(
                            "{:url('power/delMenu')}",
                            {"id": treeNode.id},
                            function (data) {
                                if (data.code > 0) {
                                    resetTreeObj(data.data);
                                    //var callbackFlag = $("#callbackTrigger").attr("checked");
                                    //zTree.removeNode(treeNode, callbackFlag);
                                } else {
                                    alert(data.msg);
                                }
                            }
                    );

                } else {
                    return false;
                }
            }});//confirm("确认删除 节点 -- " + treeNode.name + " 吗？");
        return false;
    }
    /**
     * 是否显示删除按钮[父节点不能删除]
     * @param {type} treeId
     * @param {type} treeNode
     * @returns {Boolean}
     */
    function showRemoveBtn(treeId, treeNode) {
        //return !treeNode.isFirstNode;
        return !treeNode.children;
    }
    function showRenameBtn(treeId, treeNode) {
        return !treeNode.isLastNode;
    }
    function showLog(str) {
        if (!log)
            log = $("#log");
        log.append("<li class='" + className + "'>" + str + "</li>");
        if (log.children("li").length > 8) {
            log.get(0).removeChild(log.children("li")[0]);
        }
    }
    function getTime() {
        var now = new Date(),
                h = now.getHours(),
                m = now.getMinutes(),
                s = now.getSeconds(),
                ms = now.getMilliseconds();
        return (h + ":" + m + ":" + s + " " + ms);
    }

    var newCount = 1;
    function addHoverDom(treeId, treeNode) {

        //console.log(treeNode);
        var sObj = $("#" + treeNode.tId + "_span");
        if (treeNode.editNameFlag || $("#addBtn_" + treeNode.tId).length > 0)
            return;

        //判断三级菜单不能添加子菜单[这里级别级值比数据库中小1]
        if (treeNode.level >= 3) {
            return;
        }

        var addStr = "<span class='button add' id='addBtn_" + treeNode.tId
                + "' title='添加' onfocus='this.blur();'></span>";
        sObj.after(addStr);
        var btn = $("#addBtn_" + treeNode.tId);
        if (btn)
            btn.bind("click", function () {
                showAddModal(treeNode);
                return false;
            });
    }
    function removeHoverDom(treeId, treeNode) {
        $("#addBtn_" + treeNode.tId).unbind().remove();
    }

    /**
     * 编辑菜单
     * @param {type} node
     * @returns {undefined}
     */
    function showEditModal(node) {
        editNodeId = node.id;
        editType = 2;
        $("#menuModal").modal('show');
        modalReset();
        $("#menu-type").val(1);//
        $("#menu-id").val(node.id);
        $("#menu-parentid").val(node.parentid);
        $("#menu-name").val(node.name);
        $("#menu-c").val(node.c);
        $("#menu-a").val(node.a);
        $("#menu-data").val(node.data);
        $("#menu-order").val(node.list_order);
        $("#menu-display").val(node.display);
        $("#menu-level").val(node.level);
    }

    /**
     * 添加菜单
     * @param {type} node
     * @returns {undefined}
     */
    function showAddModal(node) {
        editNodeId = node.id;
        editType = 1;
        $("#menuModal").modal('show');
        modalReset();
        $("#menu-parentid").val(node.id);
        $("#menu-level").val(node.level - 0 + 1);
    }
    
    /**
     * Ajax 上传表单信息
     * @returns {undefined}
     */
    function ajaxSaveMenu(){
        var formData = $("#menuModal #menu-form").serializeArray();
        var data = {};
        $.each(formData, function () {
            data[this.name] = this.value;
        });
        stbAjax("{:url('power/editMenu')}", data, function (result) {
            console.log(result);
            $("#menuModal").modal('hide');
            resetTreeObj(result.data);
        });
    }
    
    /**
     * 重新生成树结构
     */
    function resetTreeObj(zNodes) {
        zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
        //console.log(editNodeId);
        var editNode = zTreeObj.getNodeByParam('id', editNodeId, null);
        //console.log(editNode);
        if (editType > 1) {
            if (editNode.isParent) {
                zTreeObj.expandNode(editNode, true, true, true);
            } else {
                var parentNode = zTreeObj.getNodeByTId(editNode.parentTId);
                //console.log(parentNode);
                zTreeObj.expandNode(parentNode, true, false, true);
            }
        } else {
            zTreeObj.expandNode(editNode, true, false, true);
        }
    }

    /**
     * 重置表单
     * @returns {undefined}
     */
    function modalReset() {
        fromReset('menu-form');
        $("#menu-display").val(1);
        $("#menu-level").val(1);
    }

    $(document).ready(function () {
        zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
        //$("#selectAll").bind("click", selectAll);
    });
</SCRIPT>

<div class="panel panel-info">
    <div class="panel-heading">
        后台菜单列表
        <small><a href="javascript:showAddModal({id:0,level:1});" title="添加菜单项">
                添加一级菜单
            </a></small>
        <BUTTON class="btn btn-sm btn-primary  pull-right" onclick="refresh('menu')">更新菜单缓存</BUTTON>
    </div>
    <div class="panel-body">
        <!--p class="bg-danger">
            1，菜单分为三级。<br/>
            2，一级菜单统一是父节点，不执行任何操作或显示页面。<br/>
            3，一级、二级可以控制是否显示。<br/>
            4，二级可以直接直接显示页或直接执行某项操作,[建议将不显示的二级菜单归属到其它相近功能的二级菜单下，变为三级菜单]<br/>
            5，三级菜单一律不显示。
        </p-->
        <ul id="treeDemo" class="ztree"></ul>
        <ul id="log"></ul>
    </div>
</div>


<!-- Modal -->
<div class="modal fade" id="menuModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">编辑菜单</h4>
            </div>
            <form action="{:url('power/editMenu')}" class="form-horizontal jqueryfrom" id='menu-form' method="post">
                <input type='hidden' name='id' id='menu-id' value='' />
                <input type='hidden' name='parentid' id='menu-parentid' value='' />
                <input type='hidden' name='level' id='menu-level' value='1' />
                <div class="modal-body">
                    <form class="form-horizontal">
                        <div class="form-group">
                            <label for="menu-name" class="col-sm-2 control-label">菜单名称</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="menu-name" placeholder="" name='name' required />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="menu-c" class="col-sm-2 control-label">控制器</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="menu-c" name='c' placeholder="m">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="menu-a" class="col-sm-2 control-label">方法</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="menu-a" name='aa' placeholder="a">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="menu-data" class="col-sm-2 control-label">参数</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="menu-data" name='data' placeholder="data">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="menu-order" class="col-sm-2 control-label">排序</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" id="menu-order" name='list_order' placeholder="排序值">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="menu-display" class="col-sm-2 control-label">是否显示</label>
                            <div class="col-sm-3">
                                <select class="form-control" id="menu-display" name="display">
                                    <option value="1">是</option>
                                    <option value="0">否</option>
                                </select>
                            </div>
                        </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" onclick="ajaxSaveMenu()">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>